<?php
namespace plugin\ky_black\app\admin\model;

use support\Model;

class Member extends Model
{
    /**
     * 关联到模型的数据表
     *
     * @var string
     */
    protected $table = 'ky_user';

    /**
     * 主键
     *
     * @var string
     */
    protected $primaryKey = 'user_id';

    /**
     * 可以批量赋值的属性
     *
     * @var array
     */
    protected $fillable = [
        'type',
        'status',
        'name',
        'phone',
        'id_card',
        'gender',
        'birthday',
        'email',
        'company_name',
        'business_license',
        'legal_representative',
        'company_address',
        'contact_phone',
        'company_email',
        'invoice_type',
        'tax_number',
        'bank_name',
        'bank_account',
        'invoice_address',
        'invoice_phone',
        'emergency_contact',
        'emergency_phone'
    ];

    /**
     * 类型转换
     *
     * @var array
     */
    protected $casts = [
        'status' => 'boolean',
        'birthday' => 'date',
        'created_at' => 'datetime',
        'updated_at' => 'datetime'
    ];

    /**
     * 关联账号信息
     */
    public function userAccount()
    {
        return $this->hasOne(UserAccount::class, 'user_id', 'user_id');
    }
} 